# encoding:utf-8
from flask.ext.wtf import Form
from wtforms import SelectField, StringField, SubmitField, BooleanField, DateField, PasswordField
from wtforms.validators import Optional, DataRequired, Email


class SelfDataRequired(DataRequired):
    def __init__(self):
        super(SelfDataRequired, self).__init__(u"此项为必填项")


class LoginForm(Form):
    username = StringField(u'用户名', validators=[SelfDataRequired()])
    password = PasswordField(u'密码', validators=[SelfDataRequired()])
    submit = SubmitField(u'登录')


class UserForm(Form):
    name = StringField(u'员工姓名', validators=[SelfDataRequired()])
    gender = SelectField(
        u'性别', choices=[(1, u'男'),(2, u'女'),(3, u'未知')],
        validators=[SelfDataRequired()], default=3, coerce=int)
    email = StringField(
        u'企业邮箱', validators=[Email(), SelfDataRequired()])
    phone = StringField(u"联系电话", validators=[SelfDataRequired()])
    role_id = SelectField(u"角色", choices=[],coerce=int,
                          validators=[SelfDataRequired()])
    is_locked = BooleanField(u'是否离职', default=False)
    submit = SubmitField(u'提交')


class SearchForm(Form):
    keyword=StringField(u'关键字', validators=[Optional()])
    submit = SubmitField(u'提交')